package com.xmall.utils;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import com.xmall.define.request.thirdparty.UploadRequest;
import org.springframework.web.multipart.MultipartFile;

import java.util.Date;

public class FileUtils {

    public static String dateDirectory() {
        return DateUtil.format(new Date(), "yyyy/MM/dd");
    }

    public static String createFilePath(String uuid, MultipartFile file, UploadRequest request) {
        String directory = FileUtils.dateDirectory() + "/" + request.getDirectory();
        String fileName = uuid + "." + FileUtil.getSuffix(file.getOriginalFilename());
        return directory + "/" + fileName;
    }
}
